package triggerhelper.errorChecks.possibleErrors;

import java.awt.Component;
import javax.swing.JOptionPane;
import triggerhelper.errorChecks.PossibleError;

public class MaxLength implements PossibleError{

    private int max;

    public MaxLength(int max_){
        max = max_;
    }

    public boolean check(String input, String name, Component parent) {
        boolean valid = true;
        if(input.length() > max){
            JOptionPane.showMessageDialog(parent, "I'm sorry, the " + name + " cannot be longer than " + max + " characters.");
            valid = false;
        }
        return valid;
    }



}
